package com.david.webtest

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import com.david.webtest.utils.CommonUtils
import com.tencent.smtt.sdk.QbSdk
import java.util.*

//doc、docx、ppt、pptx、xls、xlsx、pdf、txt、epub
class X5TextReader:Activity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_text_reader)

        val filePath: String?
        val intent = intent
        val action = intent.action
        if (Intent.ACTION_VIEW == action) {
            val uri = intent.data

            filePath =
                CommonUtils.getFilePathFromContentUri(uri, contentResolver)

            val params = HashMap<String, String>()
            params.put("style", "1")
            params.put("local", "true")
//        params.put("memuData", jsondata);
            QbSdk.openFileReader(this,filePath, params
            ) { p0 -> //open success fileReaderClosed
                if ("fileReaderClosed" == p0) {
                    finish()
                }
            }
        }


    }
}